﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LIMS.Shared;
using LIMS.Entities;
//using log4net.Core;
using Castle.Core.Logging;

namespace LIMS.Windows
{
    public partial class Dashboard:LIMSPageBase<GroupManagementPresenter> ,IGroupManagementView
    //public partial class Dashboard : Form
    {
        #region IGroupManagementView Members

        public int CurrentIndex
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public List<LIMS.Entities.Group> oGroupList
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public List<LIMS.Entities.User> oUsers
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion

        public Dashboard()
        {
            InitializeComponent();
        }
          ILogger oLogger = null;
       // IGroupManagementView oview 
        private void Dashboard1_Load(object sender, EventArgs e)
        {
            //GroupManagementPresenter op = new GroupManagementPresenter(this, oLogger);
            string s = string.Empty;
            s= this.Presenter.ShowMessage();

            picHeader.Width = this.Width - 20;
            picFooter.Top = this.Bottom - 60;
            picFooter.Width = this.Width - 20;
            //btnLogout.Left = this.Width - 20- btnLogout.Width;
            pnlUser.Left = this.Width - 20 - pnlUser.Width;
            
            lblWelcome.Text = "Welcome: " + SharedResource.gLoggedinUser.UserName;
            lblLastLogin.Text = "[Last login: " +  SharedResource.gLoggedinUser.LastLoginDateTime + "]";

            //update user's new loginDateTime to DB
            SharedResource.gLoggedinUser.LastLoginDateTime= DateTime.Now;
            SharedResource.UpdateUser(SharedResource.gLoggedinUser);

        }

        
        private void Dashboard_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void btnManageUser_Click(object sender, EventArgs e)
        {
            UserManagement frmUM = new UserManagement();
            frmUM.ShowDialog();
        }
       

        
         /// <summary>
        /// btnManageDept_Click
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
        private void btnManageDept_Click(object sender, EventArgs e)
        {
            DepartmentManagement frmDP = new DepartmentManagement();
            frmDP.ShowDialog();
        }
        /// <summary>
        /// button4_Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {

            SiteManagement frmSM = new SiteManagement();
            frmSM.ShowDialog();

        }

        private void btnManagePlant_Click(object sender, EventArgs e)
        {

            PlantManagement frmPM = new PlantManagement();
            frmPM.ShowDialog();

        }

        private void btnManageUser_MouseEnter(object sender, EventArgs e)
        {
            btnManageUser.UseVisualStyleBackColor = false;
            btnManageUser.BackColor = Color.FromArgb(254, 238, 150);
        }

        private void btnManageUser_MouseLeave(object sender, EventArgs e)
        {
            btnManageUser.UseVisualStyleBackColor = true;
            btnManageUser.BackColor = Color.Snow;
        }

        private void button4_MouseEnter(object sender, EventArgs e)
        {
            button4.UseVisualStyleBackColor = false;
            button4.BackColor = Color.FromArgb(254, 238, 150);
        }

        private void button4_MouseLeave(object sender, EventArgs e)
        {
            button4.UseVisualStyleBackColor = true;
            button4.BackColor = Color.Snow;
        }

        private void btnManageDept_MouseEnter(object sender, EventArgs e)
        {
            btnManageDept.UseVisualStyleBackColor = false;
            btnManageDept.BackColor = Color.FromArgb(254, 238, 150);
        }
          
        private void btnManageDept_MouseLeave(object sender, EventArgs e)
        {
            btnManageDept.UseVisualStyleBackColor = true;
            btnManageDept.BackColor = Color.Snow;
        }

        private void btnProducts_MouseEnter(object sender, EventArgs e)
        {
            btnProducts.UseVisualStyleBackColor = false;
            btnProducts.BackColor = Color.FromArgb(254, 238, 150);
        }

        private void btnProducts_MouseLeave(object sender, EventArgs e)
        {
            btnProducts.UseVisualStyleBackColor = true;
            btnProducts.BackColor = Color.Snow;
        }

        private void btnPlants_MouseEnter(object sender, EventArgs e)
        {
            btnPlants.UseVisualStyleBackColor = false;
            btnPlants.BackColor = Color.FromArgb(254, 238, 150);
        }

        private void btnPlants_MouseLeave(object sender, EventArgs e)
        {
            btnPlants.UseVisualStyleBackColor = true;
            btnPlants.BackColor = Color.Snow;
        }

        private void btnPlants_Click(object sender, EventArgs e)
        {
            PlantManagement oPM = new PlantManagement();
            oPM.ShowDialog();
        }

        private void btnProducts_Click(object sender, EventArgs e)
        {
            AddProduct oAP = new AddProduct();
            oAP.ShowDialog();
        }


        private void btnSupplier_Click(object sender, EventArgs e)
        {
            SupplierManagement oSPFrm = new SupplierManagement();
            oSPFrm.ShowDialog();
         
        }

        private void btnManufacturer_Click(object sender, EventArgs e)
        {
            ManufacturerManagement oMMFrm = new ManufacturerManagement();
            oMMFrm.ShowDialog();
        }


        private void btnUserRights_Click(object sender, EventArgs e)
        {
            UserTypePermissions oUserRights = new UserTypePermissions();
            oUserRights.ShowDialog();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            UserTypePermissions oUserRights = new UserTypePermissions();
            oUserRights.ShowDialog();
        }

        private void btnUserRights_MouseEnter(object sender, EventArgs e)
        {
            btnUserRights.UseVisualStyleBackColor = false;
            btnUserRights.BackColor = Color.FromArgb(254, 238, 150);
        }

        private void btnUserRights_MouseLeave(object sender, EventArgs e)
        {
            btnUserRights.UseVisualStyleBackColor = true;
            btnUserRights.BackColor = Color.Snow;
        }

        private void btnLogout_Click(object sender, EventArgs e)
        {
            DialogResult oResult = MessageBox.Show("Do you want to exit this program?", "Logout", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (oResult.Equals(DialogResult.OK))
                Application.Exit();
        }

        private void btnEditProfile_Click(object sender, EventArgs e)
        {
            UserProfile oForm = new UserProfile();
            oForm.ShowDialog();
        }

        private void btnChangePassword_Click(object sender, EventArgs e)
        {
            ChangeUserPassword oForm = new ChangeUserPassword();
            oForm.ShowDialog();
        }

    }
}
